//=============================================================================
// Utilities
//=============================================================================

Yanfly.Util = Yanfly.Util || {};

if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.5.0') {

    Yanfly.Util.toGroup = function (inVal) {
        if (typeof inVal === 'string') return inVal;
        if (!Yanfly.Param.DigitGroup) return inVal;
        return inVal.toLocaleString('en');
        return inVal.replace(/(^|[^\w.])(\d{4,})/g, function ($0, $1, $2) {
            return $1 + $2.replace(/\d(?=(?:\d\d\d)+(?!\d))/g, "$&,");
        });
    };

} else {

    Yanfly.Util.toGroup = function (inVal) {
        if (typeof inVal !== 'string') { inVal = String(inVal); }
        if (!Yanfly.Param.DigitGroup) return inVal;
        return inVal.toLocaleString('en');
        return inVal.replace(/(^|[^\w.])(\d{4,})/g, function ($0, $1, $2) {
            return $1 + $2.replace(/\d(?=(?:\d\d\d)+(?!\d))/g, "$&,");
        });
    };

} // Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.5.0'



Yanfly.Util.displayError = function (e, code, message) {
    console.log(message);
    console.log(code || 'NON-EXISTENT');
    console.error(e);
    if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") return;
    if (Utils.isNwjs() && Utils.isOptionValid('test')) {
        if (!require('nw.gui').Window.get().isDevToolsOpen()) {
            require('nw.gui').Window.get().showDevTools();
        }
    }
};